package de.koller.worlders.engine.util.console;

import de.koller.oceanFramework.math.Vec;
import de.koller.worlders.WorldersRoot;
import de.koller.worlders.engine.entity.IAABB;
import de.koller.worlders.engine.entity.zone.build.PlanetBuild;
import java.util.StringTokenizer;

public class ConsoleListener {

	private final WorldersRoot wroot;

	public ConsoleListener( WorldersRoot wroot ) {
		this.wroot = wroot;
	}
	
	public void handle( String command ) {
		IAABB a = wroot.gamePlayer.getGPO().getAABB();
		Vec p = new Vec();
		p.setX( a.getPosition().getX() + a.getSize().getX()*.5f );
		p.setY( a.getPosition().getY() + a.getSize().getY()*.5f );
		
		if( command.equals( "generate tdi" ) )
			new PlanetBuild( wroot ).generateTopDownLimbSandIsland( p.getXi(), p.getYi() );
		if( command.equals( "show worldelements" ) )
			wroot.rendering.showWorldElements();
		if( command.equals( "show guielements" ) )
			wroot.rendering.showGuiElements();
		if( command.startsWith( "movePlayer " ) ) {
			StringTokenizer st = new StringTokenizer( command );
			st.nextToken();
			wroot.gamePlayer.getGPO().getAABB().getPosition().set( Integer.parseInt( st.nextToken() ), Integer.parseInt( st.nextToken() ) );
		}
			
	}
	
}
